package com.ebs.md.fxmonitor.marketmonitor.model;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/model/SelfMatchSingleFact.java $
 *  $Revision: #4 $  $Change: 116324 $  $DateTime: 2012/10/29 12:27:50 $  $Author: Arik.Sher $
 */

import java.util.Calendar;

import com.ebs.md.api.Rate;
import com.ebs.md.api.deal.IDeal;


public class SelfMatchSingleFact
extends AbsSingleFactByTrader
{
	// gened with Eclipse
	private static final long serialVersionUID = 5311180628387974131L;

	final protected IDeal   deal;
	final protected String  dealId;
	final protected boolean automatch; // maybe could be determined from Deal.isAutomatch.
	
	public SelfMatchSingleFact(String configInstanceName, OBCNew passiveQuote, IDeal deal, boolean isAutomatch) {
		super( configInstanceName, passiveQuote);
		this.deal = deal;
		this.dealId = deal.getId();
		this.automatch = isAutomatch;
	}

	public Integer getFirmId() {
		return deal.getFirmId();
	}
	public String getDealId() {
		return dealId;
	}
	public String getMakerFloorCode() {
		return deal.getFloorCode();
	}
	public String getMakerOrderId() {
		return deal.getOrderId();
	}
	public String getTakerFloorCode() {
		return deal.getCPFloorCode();
	}
	public String getTakerOrderId() {
		return deal.getCPOrderId();
	}
	public long getDealAmount() {
		return deal.getAmount();
	}
	public Rate getDealRate() {
		return deal.getRate();
	}
	public Calendar getDealTime() {
		return deal.getTime();
	}
	public long getDealTimestamp() {
		return deal.getTime().getTimeInMillis();
	}
	@Override
	public long getTimestamp() {
		return getDealTimestamp();
	}
	public boolean isAutomatch() {
		return automatch;
	}

	// gened by eclipse on "dealId"
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dealId == null) ? 0 : dealId.hashCode());
		return result;
	}
	// gened by eclipse on "dealId"
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SelfMatchSingleFact other = (SelfMatchSingleFact) obj;
		if (dealId == null) {
			if (other.dealId != null)
				return false;
		} else if (!dealId.equals(other.dealId))
			return false;
		return true;
	}

	protected String additionalFields4toString() {
		return 
		       super.additionalFields4toString()
			+ ", dealId=" + dealId
			+ ", firmId=" + getFirmId()
			+ ", makerFloorCode=" + getMakerFloorCode()
			+ ", makerQuoteId="   + getMakerOrderId()
			+ ", takerFloorCode=" + getTakerFloorCode()
			+ ", takerQuoteId="   + getTakerOrderId()
			+ ", dealTimestamp="  + getDealTimestamp()
			+ ", automatch="      + automatch
			+ "]";
	}

}
